<template>
	<view style="margin-top: 180rpx;" v-if="user.frentLink!==5&&user!==''">
		<navbox title="用户管理"></navbox>
		<view class="u-page">
			<u-list @scrolltolower="scrolltolower">
				<u-list-item v-for="(item, index) in urls" :key="index">
					<u-cell :title="item.nickName" @click="updateUser(item)">
						<view slot="title" class="u-slot-title"
							style="display: flex;align-items: center;justify-content: center;">
							<u-avatar slot="icon" shape="square" size="35" :src="item.picUrl"
								customStyle="margin: -3px 5px -3px 0"></u-avatar>
							<u--text :text="item.nickName" color="#878787" size="13">
							</u--text>
							<u--text :text="item.status===0?'正常':'禁用'" color="#878787" size="13">
							</u--text>
							<u--text text="普通用户" color="#878787" size="13" v-if="item.frentLink===5"></u--text>
							<u--text text="友链管理员" color="#878787" size="13" v-if="item.frentLink===3"></u--text>
							<u--text text="会员" color="#878787" size="13" v-if="item.frentLink===0"></u--text>
							<u--text text="会员/友链" color="#878787" size="13" v-if="item.frentLink===30"></u--text>
							<u--text :text="item.realName!== ''&&item.realName!== null ? item.realName:''"
								color="#878787" size="13"></u--text>
						</view>
					</u-cell>
				</u-list-item>
			</u-list>
 
		</view>
	</view>
</template>

<script>
	import navbox from '../components/navbox/navbox.vue'
	export default {
		data() {
			return {
 
 
				urls: [],
				page: {
					pageSize: 18,
					pageNum: 1,
				},
				total: '',
				time:''
			}
		},
		onPullDownRefresh() {
			uni.showLoading({
				title: '加载中'
			});
			this.page.pageNum = 1
			this.getList() 
			this.timer = setTimeout(() => {
				uni.stopPullDownRefresh()
			}, 1000)
		},
		onLoad() {
			if (this.timer) {
				clearTimeout(this.timer); // 清除定时器  
			}
			uni.showLoading({
				title: '加载中'
			});
			this.getList()
		},
		methods: {
			async scrolltolower() {
				const that = this
				if (this.urls.length < this.total) {
					this.page.pageNum++
					uni.showLoading({
						title: '加载中'
					});
					uni.request({
						url: that.$baseurl + "/wexinLogin/sgArticle/userList",
						method: 'POST',
						data: that.page,
						success(res) {
							console.log(res)
							that.urls = [...that.urls, ...res.data.data.records]
						}
					})
			
					setTimeout(function() {
						unis.hideLoading();
					}, 800);
				}
			},
			async getList() {
				const res = await this.$myRuquest({
					url: '/wexinLogin/sgArticle/userList',
					method: "post",
					data: this.page
				})
				console.log(res)
				this.urls = res.data.data.records
				this.total = res.data.data.total
				uni.hideLoading();
			},
			updateUser(item){
		      uni.navigateTo({
		      	url:'/pagesa/userDetail/userDetail?id='+item.id+'&nickName='+item.nickName+'&status='+item.status+'&frentLink='+item.frentLink+'&realName='+item.realName
		      })
			},
			open() {
				// console.log('open');
			},
			close() {
				this.show = false
				// console.log('close');
			}
		},
		components: {
			"navbox": navbox
		},
	}
</script>

<style>

</style>
